fix(UI): refactor tree api to return all parent tree#1169
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the tree API to return complete parent tree information. Key changes include renaming and enhancing type definitions for tree responses, updating API handler signatures to use references instead of owned paths, and modifying the API router logic to build a comprehensive file tree structure.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| moon/packages/types/generated.ts | Renamed and updated tree-related types to support parent tree responses |
| mono/src/api/mod.rs | Changed api_handler parameter type from PathBuf to &Path |
| mono/src/api/api_router.rs | Updated tree endpoints to build and return a TreeResponse structure |
| ceres/src/model/git.rs | Added TreeResponse and FileTreeItem types consistent with new API design |
| ceres/src/api_service/mod.rs | Refactored get_tree_info to use &Path and a mapping transformation |
Comment on lines
+146
to
+159
| let mut current = String::new(); | ||
| let mut segments = query.path.split('/').peekable(); | ||
|
|
||
| while let Some(segment) = segments.next() { | ||
| if segment.is_empty() { | ||
| current = "/".to_string(); | ||
| parts.push(current.clone()); | ||
| } else if segments.peek().is_some() { | ||
| if current != "/" { | ||
| current.push('/'); | ||
| } | ||
| current.push_str(segment); | ||
| parts.push(current.clone()); | ||
| } |
There was a problem hiding this comment.
[nitpick] Consider normalizing the path segments to handle edge cases such as multiple consecutive slashes, ensuring that the generated 'parts' accurately represent the intended file path hierarchy.
Suggested change
| let mut current = String::new(); | |
| let mut segments = query.path.split('/').peekable(); | |
| while let Some(segment) = segments.next() { | |
| if segment.is_empty() { | |
| current = "/".to_string(); | |
| parts.push(current.clone()); | |
| } else if segments.peek().is_some() { | |
| if current != "/" { | |
| current.push('/'); | |
| } | |
| current.push_str(segment); | |
| parts.push(current.clone()); | |
| } | |
| let normalized_path = PathBuf::from(query.path); | |
| for component in normalized_path.components() { | |
| let part = component.as_os_str().to_string_lossy().to_string(); | |
| parts.push(part); |
genedna
approved these changes
Jun 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.